<include file="Public:header" />
<include file="Public:leftside" />
<style type="text/css">
	
	.pagination a {
		display: block;
		float: left;
		border: 1px solid #eee;
		padding: 2px 4px;
		margin: 0 2px;
	}
	
	.pagination span {
		display: block;
		float: left;
		border: 1px solid #eee;
		padding: 2px 4px;
		margin: 0 2px;
		background: #65bd77;
		color: #fff;
	}
</style>
<div class="main-content">
	<div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs">
		<ul class="breadcrumb">
			<li> <i class="icon-home home-icon"></i> <a href="/">首页</a> </li>
			<li class="active">商城商品管理</li>
		</ul>
	</div>
	<div class="page-content">
	<div class="row panel-body" style="width: 100%;margin: 5px auto;padding: 15px 0;">
		<a href="{:U('Shop/index')}" class="btn btn-sm btn-primary">商品管理</a>
		<a href="{:U('Shop/ticketTypeList')}" class="btn btn-sm btn-default">商品分类</a>
		<a href="{:U('Shop/brandList')}" class="btn btn-sm btn-default">商品品牌</a>
		<a href="{:U('Shop/attributelist')}" class="btn btn-sm btn-default">商品类型</a>
	</div>
    <div class="search_box">
    	<form id="mallSearch" action="__CONTROLLER__/index/" method="get" class="form-inline">
        	<section class="panel-default m-b-sm">
				<div class="alert alert-info">
					<p>
	                  <i class="fa fa-hand-o-right m-r-xs"></i><strong>操作提示</strong>
	                </p>
                    <p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>该页面展示了商城所有的商品信息，可对商品进行编辑修改操作。</p>
                    <p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>可输入商品名称关键字进行搜索。</p>
            	</div>
			</section>
        <div class="row padder-v">
		<div class="col-sm-2">
			<a href="__CONTROLLER__/add/" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i> 添加商品 </a> 
					
		</div>
		<div class="col-sm-2">
		<input type="text" name="id" value="<?=$_GET['id']?>" class="form-control input-sm" placeholder="请输入商品ID"/>
			
		</div>
		<div class="col-sm-2">
		<input type="text" name="title" value="{$_GET['title']|explode='_',###|implode=' ',###}" class="form-control input-sm" placeholder="请输入商品名称"/>

			
		</div>
		<div class="col-sm-2">
			<select class="input-sm form-control" id="shop_type" name="type_id">
                    	<option value="0">请选择商品分类</option>
                    	 <volist name="classTree" id="row">
		    					<option value="{$row.id}" <?=I('get.type_id') === $row['id']?'selected':''?> >{$row.bids|getBtypeId=###}</option>
						 </volist>
            </select>			
		</div>
		<div class="col-sm-2 ">
			<select class="input-sm form-control" id="shop_type" name="status_id">
                    	<option value="0">请选择商品状态</option>
                    	<option value="1" <?=I('get.status_id') == 1?'selected':''?> >上架</option>
                    	<option value="2" <?=I('get.status_id') == 2?'selected':''?> >下架</option>
                    	<option value="3" <?=I('get.status_id') == 3?'selected':''?> >已删除</option>
                    	<option value="4" <?=I('get.status_id') == 4?'selected':''?> >无货</option>
			</select>			
		</div>
		<div class="col-sm-2 navbar-right" >
			<button class="btn btn-sm btn-default" type="submit" >搜索</button>
			<a href="{:U('Shop/index')}" class="btn btn btn-info btn-sm" >清空</a>
		</div>
	</div>
     
        </form>
    </div>
    <div class="table-header" style="height:45px; line-height:45px; margin-top:10px;padding-right: 15px;">
        	<div style="float: left;">商品列表</div>
          <div class="fr">合计总数：<span class="font_orange font_bold">{$count}</span></div>
    </div>
    <div class="listContent">
    	<table class="table table-striped table-bordered table-hover" width="100%" border="0" cellpadding="0" cellspacing="0" >
            <thead>
        	<tr class="f_black bg_gray">
				<th style="width: 20px;">
					<input type="checkbox" class="ace" />
					<span class="lbl"></span>
				</th>
                <th style="width: 50px;" align="center">ID</th>
                <th style="width: 30%;">商品名称</th>
               
                <th>库存</th>
                <th>原价</th>
                <th>售价</th>
                <th>店铺名</th>
                <th>发布时间</th>
                <th>商品状态</th>
                <th>首页推荐</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="array" id="row">
	            <tr class="list" id="list{$row['id']}">
            		<td><input type="checkbox" name="id[]" class="ace aceid" value="{$row.id}" />
								<span class="lbl"></span></td>
                	<td>{$row.id}</td>
		            <td style="text-align:left;">{$row.title}</td>
		            <td>{$row.num}</td>
		            <td>{$row.oprice}</td>
		            <td>{$row.price}</td>
		            <td>{$row.storename}</td>
		            <td>{$row.addtime|date='Y-m-d H:i',###}</td>
		            <td><?=$row['ishidden'] == '0'?'上架中':($row['ishidden'] == '1'?'已下架':($row['ishidden'] == '2'?'已删除':'无货'))?></td>
		            <td><php>if($row['isindex'] == '0'){</php><a href="{:U('Shop/checkshop',array('id'=>$row['id'],'isindex'=>1))}"><i class="fa fa-times text-danger text"></i></a><php>}</php>
	                	<php>if($row['isindex'] == '1'){</php><a  href="{:U('Shop/checkshop',array('id'=>$row['id'],'isindex'=>0))}"><i class="fa fa-check text-success text"></i></a><php>}</php>
		            </td>
	                <td>
	                	<a class="bth btn-sm btn-primary " href="{:U('Shop/add',array('id'=>$row['id']))}">编辑</a>
	                	<php>if($row['ishidden'] == '1'){</php>
	                		<a class="bth btn-sm btn-success" href="{:U('Shop/checkshop',array('id'=>$row['id'],'ishidden'=>0))}">正常上架</a>
	                		<a class="bth btn-sm btn-danger "href="{:U('Shop/checkshop',array('id'=>$row['id'],'ishidden'=>2))}">删除</a>
	                	<php>}</php>
	                	<php>if($row['ishidden'] == '0'){</php>
	                		<a class="bth btn-sm btn-danger " href="{:U('Shop/checkshop',array('id'=>$row['id'],'ishidden'=>1))}">违规下架</a>
	                	<php>}</php>
	                	<php>if($row['ishidden'] == '2'){</php>
	                		<a class="bth btn-sm btn-success " href="{:U('Shop/checkshop',array('id'=>$row['id'],'ishidden'=>1))}">恢复</a>
	                	<php>}</php>
	                </td>
	            </tr>
	        </volist>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </div>
   </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$("#toexl").click(function(){		
		var action  = "/Shop/getProExl/";	
		$("#mallSearch").attr("action",action);
		$("#mallSearch").submit();	
	});
	$("#tosea").click(function(){		
		var action  = "/Shop/<?=ACTION_NAME?>/";	
		$("#mallSearch").attr("action",action);
		$("#mallSearch").submit();	
	});
    //删除商品
    $('.delTicket').click(function(){
        var url =   '/Shop/delete/';
        var e   =   $(this);
        var ishidden    =   e.attr('ishidden');
        var string  =   ishidden == '2'?'删除':(ishidden == '1'?'下架':(ishidden == '3'?'设置为无货':'上架'));
        layer.confirm('确定执行'+string+'商品吗?',{
                btn: ['确定', '取消']},
                function(){
                    $.get(url,{id:e.attr('data'),ishidden:e.attr('ishidden')},function(data){
            			layer.msg(data,function(){
                            location.reload();
                        });
                    });
                }
			);
    });
	 $('.niceTicket').click(function(){
        var url =   '/Shop/nice/';
        var e   =   $(this);
        var nice    =   e.attr('nice');
        var string  =   nice == '0'?'取消推荐':'推荐';
        layer.confirm('确定执行'+string+'商品吗?',{
                btn: ['确定', '取消']},
                function(){
                    $.get(url,{id:e.attr('data'),isnice:e.attr('nice')},function(data){
            			layer.msg(data,function(){
                            location.reload();
                        });
                    });
                }
			);
    });
	$('body').delegate('#getType,#changeTypeList','click',function(){
		var stringFlag	=	'';
		$('.aceid:checked').each(function(){
			stringFlag	+=	stringFlag?','+$(this).val():$(this).val();
		});
		console.log(stringFlag);
		$('#typeString').val(stringFlag);
		$.get('/Shop/copyConfigHtml',{keywords:$('#keywords').val()},function(data){
			layer.closeAll();
			layer.open({
				type:1,
				area:['80%','auto'],
				content:data
			});
		});
	});
	
	$('body').delegate('.ajaxListTicketType li','click',function(){
		var type_id = $(this).attr('databids');
		layer.confirm('确定要移动到该分类',function(){
			$.get('/Shop/changeType',{type_id:type_id,ticket_id:$('#typeString').val()},function(data){
			layer.closeAll();
			var dataArray	=	data.split('|||');
			layermsglink(dataArray[1],dataArray[2]);
		});
		},function(){});
		
	});
    
});
</script>
<include file="Public:footer" />